import { OperationDynamic } from './subComps/OperationDynamic'; // 生成需要
import type { EventInfo, ProTableInfo } from './utils/types';
// 初始化配置
export const initConfig = (onEvent: (eventInfo: EventInfo) => void): ProTableInfo => {
  return {
    openScroll: false,
    showExpandable: false,
    showFooter: true,
    showOptions: true,
    showPagination: true,
    showSearch: true,
    showToolBarRender: true,
    showToolbar: true,
    tableConfig: {
      rowKey: 'id',
      tableLayout: 'auto',
      bordered: true,
      size: 'small',
      showHeader: true,
      rowSelection: true,
      scroll: { x: 1200, y: 200 },
      columns: [
        { title: '供应商名称', dataIndex: 'supplierName', valueType: 'text', value: '甘肃移动', columnOrder: 1, order: '1000', fixed: 'left' },
        { title: '供应商编码', dataIndex: 'supplierCode', valueType: 'text', value: 'code2', columnOrder: 2, order: 25, fixed: 'left' },
        { title: '供应商类型', dataIndex: 'supplierTypeTag', valueType: 'text', value: 'SUPPLIER_TYPE_HF', columnOrder: 3, order: '995' },
        { title: '合同编号', dataIndex: 'contractList', valueType: 'text', value: null, columnOrder: 4, order: 30 },
        { title: '余额（￥）', dataIndex: 'balance', valueType: 'text', value: null, columnOrder: 5, order: 6 },
        { title: '对方余额（￥）', dataIndex: 'supplierBalance', valueType: 'text', value: null, columnOrder: 6, order: 5 },
        { title: '供应商状态', dataIndex: 'enableStateTag', valueType: 'text', value: 'ENABLE_STATE_STOP', columnOrder: 7, order: '990' },
        { title: '拉单状态', dataIndex: 'pullStateTag', valueType: 'text', value: 'PULL_STATE_ZT', columnOrder: 8, order: '985' },
        { title: '供应商联系人', dataIndex: 'contactName', valueType: 'text', value: 'zhangsan', columnOrder: 9, order: '975' },
        { title: '手机号', dataIndex: 'contactPhone', valueType: 'text', value: '18629342945', columnOrder: 10, order: 15 },
        { title: '结算模式', dataIndex: 'settleModeTag', valueType: 'text', value: 'SETTLE_MODE_CJ', columnOrder: 11, order: '965' },
        { title: '运营人名', dataIndex: 'operatorUserName', valueType: 'text', value: null, columnOrder: 12, order: '970' },
        { title: '审批状态', dataIndex: 'approvalStateTag', valueType: 'text', value: 'APPROVAL_STATE_NO_APPROVAL', columnOrder: 13, order: '980' },
        { title: '创建人', dataIndex: 'creatorName', valueType: 'text', value: '蔡豪', columnOrder: 14, order: '960' },
        { title: '创建时间', dataIndex: 'createDate', valueType: 'text', value: '2022-12-06 22:46:21', columnOrder: 15, order: '955' },
        { title: '修改人', dataIndex: 'lastModifierName', valueType: 'text', value: '蔡豪', columnOrder: 16, order: '950' },
        { title: '修改时间', dataIndex: 'lastModifyDate', valueType: 'text', value: '2022-12-07 00:12:10', columnOrder: 17, order: '945' },
        { title: 'id', dataIndex: 'id', valueType: 'text', value: null, columnOrder: 18, order: 40, hideInTable: true, hideInSearch: true },
        { title: 'status', dataIndex: 'status', valueType: 'digit', value: 0, columnOrder: 19, order: 39, hideInSearch: true, hideInTable: true },
        { title: 'creator', dataIndex: 'creator', valueType: 'digit', value: 432, columnOrder: 20, order: 38, hideInTable: true, hideInSearch: true },
        { title: 'lastModifier', dataIndex: 'lastModifier', valueType: 'digit', value: 432, columnOrder: 21, order: 36, hideInSearch: true, hideInTable: true },
        { title: 'devUserName', dataIndex: 'devUserName', valueType: 'text', value: null, columnOrder: 22, order: 31, hideInTable: true, hideInSearch: true },
        { title: 'groupId', dataIndex: 'groupId', valueType: 'digit', value: 2, columnOrder: 23, order: 29, hideInSearch: true, hideInTable: true },
        { title: 'groupName', dataIndex: 'groupName', valueType: 'text', value: null, columnOrder: 24, order: 28, hideInTable: true, hideInSearch: true },
        { title: 'isInvoice', dataIndex: 'isInvoice', valueType: 'digit', value: 1, columnOrder: 25, order: 23, hideInTable: true, hideInSearch: true },
        { title: 'standardTag', dataIndex: 'standardTag', valueType: 'text', value: 'STANDARD_TJSJ', columnOrder: 26, order: 22, hideInSearch: true, hideInTable: true },
        { title: 'standardTypeTag', dataIndex: 'standardTypeTag', valueType: 'text', value: 'STANDARD_TYPE_PT', columnOrder: 27, order: 21, hideInTable: true, hideInSearch: true },
        { title: 'loginUrl', dataIndex: 'loginUrl', valueType: 'text', value: 'https://dd.com', columnOrder: 28, order: 19, hideInSearch: true, hideInTable: true },
        { title: 'loginAccount', dataIndex: 'loginAccount', valueType: 'text', value: '18923432212', columnOrder: 29, order: 18, hideInSearch: true, hideInTable: true },
        { title: 'loginPwd', dataIndex: 'loginPwd', valueType: 'text', value: '123456', columnOrder: 30, order: 17, hideInTable: true, hideInSearch: true },
        { title: 'contactEmail', dataIndex: 'contactEmail', valueType: 'text', value: '346538@qq.com', columnOrder: 31, order: 14, hideInSearch: true, hideInTable: true },
        { title: 'operatorUserId', dataIndex: 'operatorUserId', valueType: 'digit', value: 21, columnOrder: 32, order: 13, hideInTable: true, hideInSearch: true },
        { title: 'devUserId', dataIndex: 'devUserId', valueType: 'digit', value: 10, columnOrder: 33, order: 12, hideInSearch: true, hideInTable: true },
        { title: 'ipList', dataIndex: 'ipList', valueType: 'text', value: '1.1.1.1,2.2.2.2', columnOrder: 34, order: 11, hideInTable: true, hideInSearch: true },
        { title: 'callbackUrl', dataIndex: 'callbackUrl', valueType: 'text', value: 'https://www.baidu.com', columnOrder: 35, order: 10, hideInTable: true, hideInSearch: true },
        { title: 'note', dataIndex: 'note', valueType: 'text', value: '的的', columnOrder: 36, order: 7, hideInSearch: true, hideInTable: true },
        { title: 'chargeNumber', dataIndex: 'chargeNumber', valueType: 'digit', value: 70, columnOrder: 37, order: 4, hideInTable: true, hideInSearch: true },
        { title: 'charge', dataIndex: 'charge', valueType: 'digit', value: 3, columnOrder: 38, order: 3, hideInTable: true, hideInSearch: true },
        { title: 'smsSigns', dataIndex: 'smsSigns', valueType: 'text', value: "['1','2']", columnOrder: 39, order: 2, hideInSearch: true, hideInTable: true },
        {
          title: '操作',
          dataIndex: 'table-operation',
          valueType: 'option',
          columnOrder: 40,
          hideInTable: false,
          hideInSearch: false,
          fixed: 'right',
          render: (_: React.ReactNode, record: any, index: number) => {
            return OperationDynamic(['detail', 'edit', 'delete'], onEvent, { reactNode: _, record, index });
          },
        },
      ],
      headerTitle: '标题',
      tooltip: '标题 tooltip',
      footer: '表格Footer',
      options: { reload: true, search: true, density: true, fullScreen: true, setting: true },
      pagination: { position: 'bottomLeft', size: 'small', current: 1, pageSize: 20, showSizeChanger: true },
      search: { span: 6, collapseRender: true, labelWidth: 80, filterType: 'query', layout: 'horizontal' },
    },
    currentTableRecord: {},
    showModal: false,
    formType: 'detail',
    dataSource: {
      keyInfo: { key: 'id' },
      paginationInfo: { currentField: 'pageNo', pageSizeField: 'pageSize' },
      apiList: {
        list: {
          url: '/devapi/supplier/supplier/pageList',
          method: 'Post',
          afterScript: 'dataList=response.bizData.list;total=response.bizData.count;',
          parameter: {},
          body: { pageNo: 1, pageSize: 20, state: '' },
          data: [
            [
              {
                id: null,
                status: 0,
                creator: 432,
                createDate: '2022-12-06 22:46:21',
                lastModifier: 432,
                lastModifyDate: '2022-12-07 00:12:10',
                creatorName: '蔡豪',
                lastModifierName: '蔡豪',
                operatorUserName: null,
                devUserName: null,
                contractList: null,
                groupId: 2,
                groupName: null,
                supplierName: '甘肃移动',
                supplierTypeTag: 'SUPPLIER_TYPE_HF',
                supplierCode: 'code2',
                pullStateTag: 'PULL_STATE_ZT',
                isInvoice: 1,
                standardTag: 'STANDARD_TJSJ',
                standardTypeTag: 'STANDARD_TYPE_PT',
                settleModeTag: 'SETTLE_MODE_CJ',
                loginUrl: 'https://dd.com',
                loginAccount: '18923432212',
                loginPwd: '123456',
                contactName: 'zhangsan',
                contactPhone: '18629342945',
                contactEmail: '346538@qq.com',
                operatorUserId: 21,
                devUserId: 10,
                ipList: '1.1.1.1,2.2.2.2',
                callbackUrl: 'https://www.baidu.com',
                enableStateTag: 'ENABLE_STATE_STOP',
                approvalStateTag: 'APPROVAL_STATE_NO_APPROVAL',
                note: '的的',
                balance: null,
                supplierBalance: null,
                chargeNumber: 70,
                charge: 3,
                smsSigns: "['1','2']",
              },
              {
                id: null,
                status: 0,
                creator: 432,
                createDate: '2022-12-06 22:46:22',
                lastModifier: 435,
                lastModifyDate: '2022-12-06 22:46:22',
                creatorName: '蔡豪',
                lastModifierName: '侯文清',
                operatorUserName: null,
                devUserName: null,
                contractList: null,
                groupId: 2,
                groupName: null,
                supplierName: '甘肃移动2',
                supplierTypeTag: 'SUPPLIER_TYPE_HF',
                supplierCode: 'code3',
                pullStateTag: 'PULL_STATE_ZT',
                isInvoice: 1,
                standardTag: 'STANDARD_TJSJ',
                standardTypeTag: 'STANDARD_TYPE_PT',
                settleModeTag: 'SETTLE_MODE_CJ',
                loginUrl: 'https://dd.com',
                loginAccount: '18923432212',
                loginPwd: '123456',
                contactName: 'zhangsan',
                contactPhone: '18629342945',
                contactEmail: '346538@qq.com',
                operatorUserId: 21,
                devUserId: 10,
                ipList: '1.1.1.1,2.2.2.2',
                callbackUrl: 'https://www.baidu.com',
                enableStateTag: 'ENABLE_STATE_ONLINE',
                approvalStateTag: 'APPROVAL_STATE_NO_APPROVAL',
                note: '的的desd',
                balance: null,
                supplierBalance: null,
                chargeNumber: 0,
                charge: 0,
                smsSigns: null,
              },
              {
                id: null,
                status: 0,
                creator: 432,
                createDate: '2022-12-06 22:43:20',
                lastModifier: 433,
                lastModifyDate: '2022-12-06 22:43:20',
                creatorName: '蔡豪',
                lastModifierName: '冯梦娜',
                operatorUserName: null,
                devUserName: null,
                contractList: null,
                groupId: 2,
                groupName: null,
                supplierName: '甘肃移动',
                supplierTypeTag: 'SUPPLIER_TYPE_HF',
                supplierCode: 'code1',
                pullStateTag: 'PULL_STATE_ZT',
                isInvoice: 1,
                standardTag: 'STANDARD_TJSJ',
                standardTypeTag: 'STANDARD_TYPE_PT',
                settleModeTag: 'SETTLE_MODE_CJ',
                loginUrl: 'https://dd.com',
                loginAccount: '18923432212',
                loginPwd: '123456',
                contactName: 'zhangsan',
                contactPhone: '18629342945',
                contactEmail: '346538@qq.com',
                operatorUserId: 21,
                devUserId: 10,
                ipList: '1.1.1.1,2.2.2.2',
                callbackUrl: 'https://www.baidu.com',
                enableStateTag: 'ENABLE_STATE_ONLINE',
                approvalStateTag: 'APPROVAL_STATE_NO_APPROVAL',
                note: '的的',
                balance: null,
                supplierBalance: null,
                chargeNumber: 0,
                charge: 0,
                smsSigns: null,
              },
            ],
            3,
          ],
        },
        detail: { url: '/api/selectDetail', method: 'Get', afterScript: 'returnData=response.data', parameter: {}, body: {}, data: {} },
        add: { url: '/api/add', method: 'Post', afterScript: 'returnData=response.data', parameter: {}, body: {}, data: {} },
        delete: { url: '/api/delete', method: 'Get', afterScript: 'returnData=response.data', parameter: {}, body: {}, data: {} },
        update: { url: '/api/update', method: 'Post', afterScript: 'returnData=response.data', parameter: {}, body: {}, data: {} },
        deleteBatch: { url: '', method: '', afterScript: '', parameter: {}, body: {}, data: {} },
      },
    },
  };
};

export const renderColumn = (onSettingEvent: any) => {
  return (_: React.ReactNode, record: any, index: number) => {
    return OperationDynamic(['detail', 'edit', 'delete'], onSettingEvent, { reactNode: _, record, index });
  };
};
